<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>四阶Runge-Kutta公式与Adams预测校正公式求解常微分方程初值问题 | 洛沐の人间客栈</title><meta name="keywords" content="Python数值分析"><meta name="author" content="洛沐,guojiaxiang0820@gmail.com"><meta name="copyright" content="洛沐"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="本程序用经典四阶Runge-Kutta公式与Adams预测校正公式求解初值问题">
<meta property="og:type" content="article">
<meta property="og:title" content="四阶Runge-Kutta公式与Adams预测校正公式求解常微分方程初值问题">
<meta property="og:url" content="https://www.guojxblog.cn/archives/330ac4a4.html">
<meta property="og:site_name" content="洛沐の人间客栈">
<meta property="og:description" content="本程序用经典四阶Runge-Kutta公式与Adams预测校正公式求解初值问题">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/bubble.jpg">
<meta property="article:published_time" content="2022-06-01T01:36:19.000Z">
<meta property="article:modified_time" content="2023-01-18T14:10:25.903Z">
<meta property="article:author" content="洛沐">
<meta property="article:tag" content="Python数值分析">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/bubble.jpg"><link rel="shortcut icon" href="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/RS_icon.jpg"><link rel="canonical" href="https://www.guojxblog.cn/archives/330ac4a4"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><meta name="baidu-site-verification" content="code-zGPrfnFp7y"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: {"limitDay":180,"position":"top","messagePrev":"此文中创建于","messageNext":"天之前，请以最新文章为准！"},
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":500},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: true
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":50,"languages":{"author":"作者: 洛沐","link":"链接: ","source":"来源: 洛沐の人间客栈","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'mediumZoom',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#1f1f1f","position":"bottom-left"},
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: true,
  islazyload: false,
  isAnchor: true
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '四阶Runge-Kutta公式与Adams预测校正公式求解常微分方程初值问题',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-01-18 22:10:25'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          const now = new Date()
          const hour = now.getHours()
          const isNight = hour <= 6 || hour >= 18
          if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
          else if (t === 'light') activateLightMode()
          else activateDarkMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/css/style.css"><link rel="stylesheet" href="/css/iconfont.css"><link rel="stylesheet" href="/css/font-awesome.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/sviptzk/StaticFile_HEXO@latest/butterfly/css/macblack.css"><script src="/live2d-widget/autoload.js"></script><meta name="generator" content="Hexo 6.1.0"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/touxiang.jpeg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data is-center"><div class="data-item"><a href="/archives/"><div class="headline">文章</div><div class="length-num">29</div></a></div><div class="data-item"><a href="/tags/"><div class="headline">标签</div><div class="length-num">18</div></a></div><div class="data-item"><a href="/categories/"><div class="headline">分类</div><div class="length-num">7</div></a></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);" rel="external nofollow noreferrer"><i class="fa-fw fa fa-graduation-cap"></i><span> 文章</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fa fa-folder-open"></i><span> 归档</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fa fa-archive"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);" rel="external nofollow noreferrer"><i class="fa-fw fa-solid fa-heart-pulse"></i><span> 生活</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/books/"><i class="fa-fw fas fa-book-reader"></i><span> 读书</span></a></li><li><a class="site-page child" href="/photos/"><i class="fa-fw fa fa-camera-retro"></i><span> 相册</span></a></li><li><a class="site-page child" href="/music/"><i class="fa-fw fa fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 影视</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);" rel="external nofollow noreferrer"><i class="fa-fw fa-solid fa-keyboard"></i><span> 动态</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/comment/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言</span></a></li><li><a class="site-page child" href="/notes/"><i class="fa-fw fas fa-feather-alt"></i><span> 随笔</span></a></li><li><a class="site-page child" href="/ideas/"><i class="fa-fw fa-solid fa-lightbulb"></i><span> 妙想</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fa fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/bubble.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">洛沐の人间客栈</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);" rel="external nofollow noreferrer"><i class="fa-fw fa fa-graduation-cap"></i><span> 文章</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fa fa-folder-open"></i><span> 归档</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fa fa-archive"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);" rel="external nofollow noreferrer"><i class="fa-fw fa-solid fa-heart-pulse"></i><span> 生活</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/books/"><i class="fa-fw fas fa-book-reader"></i><span> 读书</span></a></li><li><a class="site-page child" href="/photos/"><i class="fa-fw fa fa-camera-retro"></i><span> 相册</span></a></li><li><a class="site-page child" href="/music/"><i class="fa-fw fa fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 影视</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);" rel="external nofollow noreferrer"><i class="fa-fw fa-solid fa-keyboard"></i><span> 动态</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/comment/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言</span></a></li><li><a class="site-page child" href="/notes/"><i class="fa-fw fas fa-feather-alt"></i><span> 随笔</span></a></li><li><a class="site-page child" href="/ideas/"><i class="fa-fw fa-solid fa-lightbulb"></i><span> 妙想</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fa fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">四阶Runge-Kutta公式与Adams预测校正公式求解常微分方程初值问题</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-06-01T01:36:19.000Z" title="发表于 2022-06-01 09:36:19">2022-06-01</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-01-18T14:10:25.903Z" title="更新于 2023-01-18 22:10:25">2023-01-18</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E7%A8%8B%E5%BA%8F%E4%BB%A3%E7%A0%81/">程序代码</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">2.8k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>12分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="四阶Runge-Kutta公式与Adams预测校正公式求解常微分方程初值问题"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="实验内容"><a href="#实验内容" class="headerlink" title="实验内容"></a>实验内容</h1><p>取步长h&#x3D;0.1，用经典四阶Runge-Kutta 公式与Adams预测校正公式求解初值问题<br><img src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/Topic_DifferEqua.png" style="zoom:72%;"><br>的数值解，并通过列表与画图将计算结果与精确解<br><img src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/Topic_True.png" style="zoom:72%;"><br>进行比较。</p>
<h1 id="算法原理"><a href="#算法原理" class="headerlink" title="算法原理"></a>算法原理</h1><h2 id="经典四阶Runge-Kutta公式"><a href="#经典四阶Runge-Kutta公式" class="headerlink" title="经典四阶Runge-Kutta公式"></a>经典四阶Runge-Kutta公式</h2><p>一阶常微分方程初值问题</p>
<img src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/formula1.png" style="zoom:80%;">

<p>的数值解法是近似计算中很重要的部分。<br>常微分方程初值问题的数值解法是求方程(8.1)的解在点列xn&#x3D;xn-1+hn(n&#x3D;0,1,…)上的近似值yn， 这里hn是xn-1到xn的步长，一般略去下标记为h。<br>常微分方程初值问题的数值解法一般分为两大类：<br>(1)单步法：这类方法在计算yn时，只用到xn+1、xn和yn,即前一步的值。因此,在有了初值以后就可以逐步往下计算。典型方法如龙格——库塔(Runge-Kutta)方法。<br>(2)多步法：这类方法在计算yn+1时，除用到xn+1、xn和yn以外，还要用<br>Yn-p(p&#x3D;1,2,…,k;k &gt; 0)，即前面k步的值。典型方法如Adams方法。<br>Runge-Kutta方法的优点是：单步法、精度高，计算过程便于改变步长，缺点是计算量较大，每前进一步需要计算四次函数值f。<br>经典的Runge-Kutta方法是一个四阶的方法，它的计算公式是:</p>
<img src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/formula2.png" style="zoom:80%;">

<h2 id="Adams预测校正公式"><a href="#Adams预测校正公式" class="headerlink" title="Adams预测校正公式"></a>Adams预测校正公式</h2><p>仿照改进的欧拉格式的构造方法，将显式和隐式两种亚当姆斯格式相匹配，构成下列亚当姆斯预测-校正公式:<br><img src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/formula3.png"><br>亚当姆斯预测-校正方法在计算yn+1时，除用到xn+1、xn和yn以外，还要用Yn-p(p&#x3D;1,2,…,k;k &gt; 0)，即前面k步的值。在实际计算时，可借助于某种单步法，如四阶龙格-库塔格式为预测——校正公式提供开始值y1,y2,y3 。<br><img src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/formula4.png" style="zoom:80%;"><br>之后利用亚当姆斯预测——校正公式求解之后的节点的值。由于亚当姆斯预测——校正公式中预报公式与校正公式具有同等精度，因此可以基于其截断误差估计及误差补偿的思想，可以提供一种提高精度的有效方法。</p>
<h1 id="程序框图"><a href="#程序框图" class="headerlink" title="程序框图"></a>程序框图</h1><img src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/runge_kutta.png" alt="图1 四阶经典龙格——库塔公式算法流程图" style="zoom:60%;">

<img src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/adams.png" alt="图2 亚当姆斯预测校正公式算法流程图" style="zoom:72%;">

<h1 id="编程实现"><a href="#编程实现" class="headerlink" title="编程实现"></a>编程实现</h1><p>本次程序采用Python的面向对象方法进行编写，其中对算法的理解以及计算微分方程数值方法公式的推导是本程序的难点所在。</p>
<p>利用所编程序，确定并计算题目中所给微分方程的数值解:</p>
<p>以下将用Python进行编程实验，分别利用四阶经典龙格——库塔公式与亚当姆斯预测校正公式对题目中所要求的微分方程初值问题进行求解，最后进行结果分析与讨论。</p>
<p>Python代码详解及运行结果如下：</p>
<h2 id="代码详解"><a href="#代码详解" class="headerlink" title="代码详解"></a>代码详解</h2><blockquote>
<p><strong>Runge_Kutta_Adams.py:</strong> **龙格-**<strong>库塔与亚达姆斯公式求解微分方程文件。</strong></p>
</blockquote>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># -*- coding: utf-8 -*-</span></span><br><span class="line"><span class="comment"># @Time    : 2022/5/29 9:16 下午</span></span><br><span class="line"><span class="comment"># @Author  : Leo</span></span><br><span class="line"><span class="comment"># @FileName: Runge_Kutta_Adams.py</span></span><br><span class="line"><span class="comment"># @Software: PyCharm</span></span><br><span class="line"><span class="comment"># @Blog    ：https://guojxblog.cn</span></span><br><span class="line"><span class="comment"># @GitHub  ：https://github.com/guojx0820</span></span><br><span class="line"><span class="comment"># @Email   ：guojiaxiang0820@gmail.com</span></span><br><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">RungeKutta_AdamsSolvingOrdinaryDifferentialEquations</span>:</span><br><span class="line">    <span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">    用龙格库塔与亚当姆斯方法求解常微分方程，并做对比分析</span></span><br><span class="line"><span class="string">    &quot;&quot;&quot;</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">__init__</span>(<span class="params">self, equs_fxy, sol_interval, y0, h_step</span>):</span><br><span class="line">        self.equs_fxy = equs_fxy  <span class="comment"># 需要求解的微分方程，y&#x27;=f(x,y),f的格式：</span></span><br><span class="line">        <span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">        def f(x,y):</span></span><br><span class="line"><span class="string">            ...</span></span><br><span class="line"><span class="string">            return dy</span></span><br><span class="line"><span class="string">        &#x27;&#x27;&#x27;</span></span><br><span class="line">        <span class="keyword">if</span> <span class="built_in">len</span>(sol_interval) == <span class="number">2</span>:</span><br><span class="line">            self.a, self.b = sol_interval[<span class="number">0</span>], sol_interval[<span class="number">1</span>]  <span class="comment"># 求解区间，a，b分别为起始值和终止值</span></span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            <span class="keyword">raise</span> ValueError(<span class="string">&quot;求解区间参数设置不规范，应为[a, b].&quot;</span>)</span><br><span class="line">        self.y0 = y0  <span class="comment"># 初值,起始条件，y0=y(0)</span></span><br><span class="line">        self.h = h_step  <span class="comment"># 求解步长（区间[a,b]n等分）</span></span><br><span class="line">        self.n = <span class="built_in">round</span>(<span class="built_in">abs</span>(self.b - self.a) / self.h)  <span class="comment"># 节点</span></span><br><span class="line">        self.true_value = <span class="literal">None</span>  <span class="comment"># 方程的真值</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">_Ord4Runge_Kutta</span>(<span class="params">self</span>):  <span class="comment"># 四阶古典Ｒｕｎｇｅ—Ｋｕｔｔａ公式</span></span><br><span class="line">        y = np.zeros((self.n, <span class="number">1</span>))</span><br><span class="line">        x = np.zeros((self.n, <span class="number">1</span>))</span><br><span class="line"></span><br><span class="line">        y[<span class="number">0</span>] = self.y0</span><br><span class="line">        x[<span class="number">0</span>] = self.a</span><br><span class="line">        K1, K2, K3, K4 = <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>  <span class="comment"># 初始化K</span></span><br><span class="line">        <span class="built_in">print</span>(<span class="string">&quot;%4s %9s %8s %10s&quot;</span>%(<span class="string">&quot;x_n&quot;</span>, <span class="string">&quot;4阶龙格-库塔&quot;</span>, <span class="string">&quot;精确解&quot;</span>, <span class="string">&quot;误差&quot;</span>))</span><br><span class="line">        <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">1</span>, self.n, <span class="number">1</span>):</span><br><span class="line">            x[i] = self.a + i * self.h</span><br><span class="line">            K1 = self.equs_fxy(x[i - <span class="number">1</span>], y[i - <span class="number">1</span>])</span><br><span class="line">            K2 = self.equs_fxy(x[i - <span class="number">1</span>] + <span class="number">1</span> / <span class="number">2</span> * self.h, y[i - <span class="number">1</span>] + <span class="number">1</span> / <span class="number">2</span> * self.h * K1)</span><br><span class="line">            K3 = self.equs_fxy(x[i - <span class="number">1</span>] + <span class="number">1</span> / <span class="number">2</span> * self.h, y[i - <span class="number">1</span>] + <span class="number">1</span> / <span class="number">2</span> * self.h * K2)</span><br><span class="line">            K4 = self.equs_fxy(x[i - <span class="number">1</span>] + self.h, y[i - <span class="number">1</span>] + self.h * K3)</span><br><span class="line">            y[i] = y[i - <span class="number">1</span>] + self.h / <span class="number">6</span> * (K1 + <span class="number">2</span> * K2 + <span class="number">2</span> * K3 + K4)</span><br><span class="line">            y_t = x[i] * (<span class="number">3</span> + x[i] ** <span class="number">2</span>) / (<span class="number">3</span> * (<span class="number">1</span> + x[i] ** <span class="number">2</span>))</span><br><span class="line">            <span class="built_in">print</span>(x[i], y[i], y_t, <span class="built_in">abs</span>(y[i] - y_t))</span><br><span class="line">        <span class="keyword">return</span> x, y</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">_Ord4Kutta</span>(<span class="params">self</span>):  <span class="comment"># 四阶Ｋｕｔｔａ公式</span></span><br><span class="line">        y = np.zeros((<span class="number">4</span>, <span class="number">1</span>))</span><br><span class="line">        x = np.zeros((<span class="number">4</span>, <span class="number">1</span>))</span><br><span class="line"></span><br><span class="line">        y[<span class="number">0</span>] = self.y0</span><br><span class="line">        x[<span class="number">0</span>] = self.a</span><br><span class="line">        K1, K2, K3, K4 = <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span></span><br><span class="line">        <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">1</span>, <span class="number">4</span>, <span class="number">1</span>):</span><br><span class="line">            x[i] = self.a + i * self.h * <span class="number">4</span></span><br><span class="line">            K1 = self.equs_fxy(x[i - <span class="number">1</span>], y[i - <span class="number">1</span>])</span><br><span class="line">            K2 = self.equs_fxy(x[i - <span class="number">1</span>] + <span class="number">1</span> / <span class="number">3</span> * self.h * <span class="number">4</span>, y[i - <span class="number">1</span>] + <span class="number">1</span> / <span class="number">3</span> * self.h * <span class="number">4</span> * K1)</span><br><span class="line">            K3 = self.equs_fxy(x[i - <span class="number">1</span>] + <span class="number">2</span> / <span class="number">3</span> * self.h * <span class="number">4</span>, y[i - <span class="number">1</span>] - <span class="number">1</span> / <span class="number">3</span> * self.h * <span class="number">4</span> * K1 + self.h * <span class="number">4</span> * K2)</span><br><span class="line">            K4 = self.equs_fxy(x[i - <span class="number">1</span>] + self.h * <span class="number">4</span>, y[i - <span class="number">1</span>] + self.h * <span class="number">4</span> * K1 - self.h * <span class="number">4</span> * K2 + self.h * <span class="number">4</span> * K3)</span><br><span class="line">            y[i] = y[i - <span class="number">1</span>] + self.h * <span class="number">4</span> / <span class="number">8</span> * (K1 + <span class="number">3</span> * K2 + <span class="number">3</span> * K3 + K4)</span><br><span class="line">        <span class="keyword">return</span> x, y</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">_Ord4ModifiedAdams</span>(<span class="params">self</span>):  <span class="comment"># 预测-校正法：四阶Adams预测-校正法</span></span><br><span class="line">        y = np.zeros((self.n, <span class="number">1</span>))</span><br><span class="line">        x = np.zeros((self.n, <span class="number">1</span>))</span><br><span class="line"></span><br><span class="line">        y[<span class="number">0</span>] = self.y0</span><br><span class="line">        x[<span class="number">0</span>] = self.a</span><br><span class="line">        temp = <span class="number">0</span></span><br><span class="line"></span><br><span class="line">        <span class="keyword">if</span> self.n &gt; <span class="number">4</span>:</span><br><span class="line">            x1, y1 = self._Ord4Kutta()</span><br><span class="line">            y[<span class="number">0</span>:<span class="number">4</span>] = y1</span><br><span class="line">            <span class="built_in">print</span>(<span class="string">&quot;%4s %6s %6s %10s&quot;</span>%(<span class="string">&quot;x_n&quot;</span>, <span class="string">&quot;亚当姆斯预测校正&quot;</span>, <span class="string">&quot;精确解&quot;</span>, <span class="string">&quot;误差&quot;</span>))</span><br><span class="line">            <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">4</span>, self.n, <span class="number">1</span>):</span><br><span class="line">                x[i] = self.a + i * self.h</span><br><span class="line">                temp = y[i] + self.h / <span class="number">24</span> * (<span class="number">55</span> * self.equs_fxy(x[i - <span class="number">1</span>], y[i - <span class="number">1</span>]) - <span class="number">59</span> * self.equs_fxy(x[i - <span class="number">2</span>], y[</span><br><span class="line">                    i - <span class="number">2</span>]) + <span class="number">37</span> * self.equs_fxy(x[i - <span class="number">3</span>], y[i - <span class="number">3</span>]) - <span class="number">9</span> * self.equs_fxy(x[i - <span class="number">4</span>], y[i - <span class="number">4</span>]))</span><br><span class="line">                y[i] = y[i - <span class="number">1</span>] + self.h / <span class="number">24</span> * (</span><br><span class="line">                        <span class="number">9</span> * temp + <span class="number">19</span> * self.equs_fxy(x[i - <span class="number">1</span>], y[i - <span class="number">1</span>]) - <span class="number">5</span> * self.equs_fxy(x[i - <span class="number">2</span>], y[</span><br><span class="line">                    i - <span class="number">2</span>]) + self.equs_fxy(x[i - <span class="number">3</span>], y[i - <span class="number">3</span>]))</span><br><span class="line">                y_t = x[i] * (<span class="number">3</span> + x[i] ** <span class="number">2</span>) / (<span class="number">3</span> * (<span class="number">1</span> + x[i] ** <span class="number">2</span>))</span><br><span class="line">                <span class="built_in">print</span>(x[i], y[i], y_t, <span class="built_in">abs</span>(y[i] - y_t))</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            <span class="keyword">raise</span> ValueError(<span class="string">&quot;四阶Adams预测-校正法节点数n必须大于4！&quot;</span>)</span><br><span class="line">        <span class="keyword">return</span> x, y</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<blockquote>
<p><strong>test_runge_kutta_adams.py:</strong> **龙格-**<strong>库塔与亚达姆斯公式测试文件。</strong></p>
</blockquote>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># -*- coding: utf-8 -*-</span></span><br><span class="line"><span class="comment"># @Time    : 2022/5/29 11:02 下午</span></span><br><span class="line"><span class="comment"># @Author  : Leo</span></span><br><span class="line"><span class="comment"># @FileName: test_runge_kutta_adams.py</span></span><br><span class="line"><span class="comment"># @Software: PyCharm</span></span><br><span class="line"><span class="comment"># @Blog    ：https://guojxblog.cn</span></span><br><span class="line"><span class="comment"># @GitHub  ：https://github.com/guojx0820</span></span><br><span class="line"><span class="comment"># @Email   ：guojiaxiang0820@gmail.com</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line"><span class="keyword">from</span> SolvingOrdinaryDifferentialEquations.Runge_Kutta_Adams <span class="keyword">import</span> RungeKutta_AdamsSolvingOrdinaryDifferentialEquations</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">def</span> <span class="title function_">equs_fxy</span>(<span class="params">x, y</span>):  <span class="comment"># 预测值</span></span><br><span class="line">    <span class="keyword">return</span> <span class="number">1</span> - <span class="number">2</span> * x * y / (<span class="number">1</span> + x ** <span class="number">2</span>)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">&quot;__main__&quot;</span>:</span><br><span class="line">    h = <span class="number">0.1</span></span><br><span class="line">    y0 = <span class="number">0</span></span><br><span class="line">    sol_interval = [<span class="number">0</span>, <span class="number">2</span>]</span><br><span class="line">    runge_kutta_adams = RungeKutta_AdamsSolvingOrdinaryDifferentialEquations(equs_fxy, sol_interval, y0, h)</span><br><span class="line">    x, y = runge_kutta_adams._Ord4Runge_Kutta()</span><br><span class="line">    t, u = runge_kutta_adams._Ord4ModifiedAdams()</span><br><span class="line">    y_t = x * (<span class="number">3</span> + x ** <span class="number">2</span>) / (<span class="number">3</span> * (<span class="number">1</span> + x ** <span class="number">2</span>))</span><br><span class="line">    plt.figure(figsize=(<span class="number">8</span>, <span class="number">6</span>))</span><br><span class="line">    plt.scatter(x, y, label=<span class="string">&#x27;Runge_Kutta_Solution-&#x27;</span> + <span class="built_in">str</span>(h), color=<span class="string">&quot;r&quot;</span>)</span><br><span class="line">    plt.scatter(t, u, label=<span class="string">&#x27;Adams_Solution-&#x27;</span> + <span class="built_in">str</span>(h), color=<span class="string">&quot;g&quot;</span>)</span><br><span class="line">    plt.plot(x, y_t, label=<span class="string">&#x27;True_Solution-&#x27;</span> + <span class="built_in">str</span>(h), color=<span class="string">&quot;b&quot;</span>)</span><br><span class="line">    plt.title(<span class="string">&quot;Runge-Kutta &amp; Adams Formula Solving Differential Equations&quot;</span>)</span><br><span class="line">    plt.legend()</span><br><span class="line">    plt.savefig(<span class="string">&quot;/Users/leo/Desktop/runge_kutta_adams_01.png&quot;</span>, dpi=<span class="number">300</span>, bbox_inches=<span class="string">&quot;tight&quot;</span>)</span><br><span class="line">    plt.figure(figsize=(<span class="number">8</span>, <span class="number">6</span>))</span><br><span class="line">    plt.plot(x, <span class="built_in">abs</span>(y - y_t), label=<span class="string">&#x27;Runge_Kutta_Error-&#x27;</span> + <span class="built_in">str</span>(h), color=<span class="string">&quot;r&quot;</span>)</span><br><span class="line">    plt.plot(x, <span class="built_in">abs</span>(u - y_t), label=<span class="string">&#x27;Adams_Error-&#x27;</span> + <span class="built_in">str</span>(h), color=<span class="string">&quot;g&quot;</span>)</span><br><span class="line">    plt.title(<span class="string">&quot;Error Curve of Runge-Kutta &amp; Adams Formula Solving Differential Equations &quot;</span>)</span><br><span class="line">    plt.legend()</span><br><span class="line">    plt.savefig(<span class="string">&quot;/Users/leo/Desktop/error_runge_kutta_adams_01.png&quot;</span>, dpi=<span class="number">300</span>, bbox_inches=<span class="string">&quot;tight&quot;</span>)</span><br><span class="line">    plt.show()</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="运行结果"><a href="#运行结果" class="headerlink" title="运行结果"></a>运行结果</h2><img src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/RK_Res.png" alt="图3 四阶经典龙格——库塔公式" style="zoom:100%;">

<p><img src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/Adm_Res.png" alt="图4 亚当姆斯预测校正公式"></p>
<p><strong>表1 4阶经典龙格-库塔公式预测值与精确值误差</strong></p>
<table>
<thead>
<tr>
<th align="center">xn</th>
<th align="center">4阶龙格-库塔公式</th>
<th align="center">精确值</th>
<th align="center">误差</th>
</tr>
</thead>
<tbody><tr>
<td align="center">0.1</td>
<td align="center">[0.09933993]</td>
<td align="center">[0.09933993]</td>
<td align="center">[2.05243127e-09]</td>
</tr>
<tr>
<td align="center">0.2</td>
<td align="center">[0.19487176]</td>
<td align="center">[0.19487179]</td>
<td align="center">[3.00356696e-08]</td>
</tr>
<tr>
<td align="center">0.3</td>
<td align="center">[0.28348614]</td>
<td align="center">[0.28348624]</td>
<td align="center">[9.79501109e-08]</td>
</tr>
<tr>
<td align="center">0.4</td>
<td align="center">[0.36321819]</td>
<td align="center">[0.36321839]</td>
<td align="center">[1.97433548e-07]</td>
</tr>
<tr>
<td align="center">0.5</td>
<td align="center">[0.43333303]</td>
<td align="center">[0.43333333]</td>
<td align="center">[3.06461535e-07]</td>
</tr>
<tr>
<td align="center">0.6</td>
<td align="center">[0.49411724]</td>
<td align="center">[0.49411765]</td>
<td align="center">[4.02982711e-07]</td>
</tr>
<tr>
<td align="center">0.7</td>
<td align="center">[0.54653196]</td>
<td align="center">[0.54653244]</td>
<td align="center">[4.73503049e-07]</td>
</tr>
<tr>
<td align="center">0.8</td>
<td align="center">[0.5918694]</td>
<td align="center">[0.59186992]</td>
<td align="center">[5.1434548e-07]</td>
</tr>
<tr>
<td align="center">0.9</td>
<td align="center">[0.63149118]</td>
<td align="center">[0.63149171]</td>
<td align="center">[5.28644923e-07]</td>
</tr>
<tr>
<td align="center">1.0</td>
<td align="center">[0.66666614]</td>
<td align="center">[0.66666667]</td>
<td align="center">[5.22604124e-07]</td>
</tr>
<tr>
<td align="center">1.1</td>
<td align="center">[0.6984912]</td>
<td align="center">[0.6984917]</td>
<td align="center">[5.02800333e-07]</td>
</tr>
<tr>
<td align="center">1.2</td>
<td align="center">[0.72786838]</td>
<td align="center">[0.72786885]</td>
<td align="center">[4.74818476e-07]</td>
</tr>
<tr>
<td align="center">1.3</td>
<td align="center">[0.75551381]</td>
<td align="center">[0.75551425]</td>
<td align="center">[4.42834343e-07]</td>
</tr>
<tr>
<td align="center">1.4</td>
<td align="center">[0.78198157]</td>
<td align="center">[0.78198198]</td>
<td align="center">[4.09698586e-07]</td>
</tr>
<tr>
<td align="center">1.5</td>
<td align="center">[0.80769193]</td>
<td align="center">[0.80769231]</td>
<td align="center">[3.77208521e-07]</td>
</tr>
<tr>
<td align="center">1.6</td>
<td align="center">[0.83295846]</td>
<td align="center">[0.8329588]</td>
<td align="center">[3.46401639e-07]</td>
</tr>
<tr>
<td align="center">1.7</td>
<td align="center">[0.85801168]</td>
<td align="center">[0.858012]</td>
<td align="center">[3.17803044e-07]</td>
</tr>
<tr>
<td align="center">1.8</td>
<td align="center">[0.88301858]</td>
<td align="center">[0.88301887]</td>
<td align="center">[2.91610862e-07]</td>
</tr>
<tr>
<td align="center">1.9</td>
<td align="center">[0.90809807]</td>
<td align="center">[0.90809834]</td>
<td align="center">[2.6782566e-07]</td>
</tr>
</tbody></table>
<p><strong>表2 亚当姆斯预测校正公式预测值与精确值误差</strong></p>
<table>
<thead>
<tr>
<th align="center">xn</th>
<th align="center">亚达姆斯预测校正公式</th>
<th align="center">精确值</th>
<th align="center">误差</th>
</tr>
</thead>
<tbody><tr>
<td align="center">0.4</td>
<td align="center">[0.79408276]</td>
<td align="center">[0.36321839]</td>
<td align="center">[0.43086437]</td>
</tr>
<tr>
<td align="center">0.5</td>
<td align="center">[0.81227136]</td>
<td align="center">[0.43333333]</td>
<td align="center">[0.37893802]</td>
</tr>
<tr>
<td align="center">0.6</td>
<td align="center">[0.83795096]</td>
<td align="center">[0.49411765]</td>
<td align="center">[0.34383331]</td>
</tr>
<tr>
<td align="center">0.7</td>
<td align="center">[0.85339412]</td>
<td align="center">[0.54653244]</td>
<td align="center">[0.30686168]</td>
</tr>
<tr>
<td align="center">0.8</td>
<td align="center">[0.86579907]</td>
<td align="center">[0.59186992]</td>
<td align="center">[0.27392915]</td>
</tr>
<tr>
<td align="center">0.9</td>
<td align="center">[0.87557522]</td>
<td align="center">[0.63149171]</td>
<td align="center">[0.24408351]</td>
</tr>
<tr>
<td align="center">1.0</td>
<td align="center">[0.8838564]</td>
<td align="center">[0.66666667]</td>
<td align="center">[0.21718973]</td>
</tr>
<tr>
<td align="center">1.1</td>
<td align="center">[0.89143105]</td>
<td align="center">[0.6984917]</td>
<td align="center">[0.19293934]</td>
</tr>
<tr>
<td align="center">1.2</td>
<td align="center">[0.89889021]</td>
<td align="center">[0.72786885]</td>
<td align="center">[0.17102136]</td>
</tr>
<tr>
<td align="center">1.3</td>
<td align="center">[0.90664655]</td>
<td align="center">[0.75551425]</td>
<td align="center">[0.1511323]</td>
</tr>
<tr>
<td align="center">1.4</td>
<td align="center">[0.91497683]</td>
<td align="center">[0.78198198]</td>
<td align="center">[0.13299485]</td>
</tr>
<tr>
<td align="center">1.5</td>
<td align="center">[0.92405599]</td>
<td align="center">[0.80769231]</td>
<td align="center">[0.11636368]</td>
</tr>
<tr>
<td align="center">1.6</td>
<td align="center">[0.93398506]</td>
<td align="center">[0.8329588]</td>
<td align="center">[0.10102626]</td>
</tr>
<tr>
<td align="center">1.7</td>
<td align="center">[0.94481281]</td>
<td align="center">[0.858012]</td>
<td align="center">[0.08680081]</td>
</tr>
<tr>
<td align="center">1.8</td>
<td align="center">[0.95655187]</td>
<td align="center">[0.88301887]</td>
<td align="center">[0.07353301]</td>
</tr>
<tr>
<td align="center">1.9</td>
<td align="center">[0.96919066]</td>
<td align="center">[0.90809834]</td>
<td align="center">[0.06109232]</td>
</tr>
</tbody></table>
<p><img src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/runge_kutta_adams_01.png" alt="图5 两种算法数值解和精确解曲线（h=0.1）"></p>
<p><img src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/error_runge_kutta_adams_01.png" alt="图6 两种算法误差曲线（h=0.1）"></p>
<p><img src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/runge_kutta_adams_001.png" alt="图7 两种算法数值解和精确解曲线（h=0.01）"></p>
<p><img src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/error_runge_kutta_adams_001.png" alt="图8 两种算法误差曲线（h=0.01）"></p>
<p><img src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/runge_kutta_adams_100.png" alt="图9 两种算法数值解和精确解曲线（[a, b]=[0, 10]"></p>
<p><img src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/error_runge_kutta_adams_100.png" alt="图10 两种算法误差曲线（[a, b]=[0, 10]"></p>
<h1 id="结果分析与讨论"><a href="#结果分析与讨论" class="headerlink" title="结果分析与讨论"></a>结果分析与讨论</h1><ul>
<li><p>从图4、5中可以看出，四阶经典龙格——库塔公式的单步法求解常微分方程的初值相对于亚当姆斯预测校正公式的双步法精度更高，收敛性更好， 程序设计简单，计算过程稳定，但对函数f(x,y)的光滑性要求较高，且计算量大，耗费机时较多。对于四阶经典龙格——库塔公式的误差一直很小，从表1、2可看出可以稳定在10-7以内。从图6可以看出，选取不同的步长与计算区间，其误差也会有所不同。误差会随着步长的减小而降低，但对题目中所给函数求解范围大于2.3左右Adams预测校正公式的误差会持续增长，直至发散，这一点的误差也会降到最低。Adams预测校正公式步长为0.01时，在0.25附近误差大到最低。</p>
</li>
<li><p>如果问题本身不适宜采用高阶方法，比如函数f(x,y)的光滑性能不太好，或者问题本身不需要太高精度的数值结果，那么采用低阶的方法并辅以适当的步长较为合适，采用更低阶的公式或Euler预测校正公式。如果函数f(x,y)的光滑性能较好，那么采用高阶Runge-Kutta公式可以得到更为准确的计算结果。</p>
</li>
<li><p>如果问题适宜采用高阶方法求解，也希望得到高精度的数值结果，则经常采用四级四阶Runge-Kutta公式。一般采用四级四阶Runge-Kutta公式提供初始值，并应用高阶线性多步公式，如四阶Adams预测校正公式求解比较理想。对于所有高阶方法来说，通过减小步长来提高精度比较合理， 因此通常不追求使用更高阶(更高精度)的数值方法。一般而言，利用显式公式计算预测值、再利用隐式公式计算校正值无论对于高阶方法还是低阶方法，总能获得比较好的稳定性。因此实际中往往采用预测校正公式进行求解。</p>
</li>
</ul>
<h1 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h1><p>[1] <strong>《数值分析》欧阳洁等。</strong></p>
<p>[2] <a target="_blank" rel="noopener external nofollow noreferrer" href="http://hwiechern.blog.163.com/blog/static/1067966220085502745478/">http://hwiechern.blog.163.com/blog/static/1067966220085502745478/</a></p>
<p>[3] <a target="_blank" rel="noopener external nofollow noreferrer" href="https://wenku.baidu.com/view/c0483326753231126edb6f1aff00bed5b9f373e5.html">https://wenku.baidu.com/view/c0483326753231126edb6f1aff00bed5b9f373e5.html</a></p>
<p>[4] <a target="_blank" rel="noopener external nofollow noreferrer" href="https://wenku.baidu.com/view/0cceafda561810a6f524ccbff121dd36a32dc4a0.html">https://wenku.baidu.com/view/0cceafda561810a6f524ccbff121dd36a32dc4a0.html</a></p>
<p>[5] <a target="_blank" rel="noopener external nofollow noreferrer" href="https://wenku.baidu.com/view/72027a10346baf1ffc4ffe4733687e21af45ffa6.html">https://wenku.baidu.com/view/72027a10346baf1ffc4ffe4733687e21af45ffa6.html</a></p>
<p>[6] <a target="_blank" rel="noopener external nofollow noreferrer" href="https://www.icode9.com/content-1-1282114.html">https://www.icode9.com/content-1-1282114.html</a></p>
<p>[7] <a target="_blank" rel="noopener external nofollow noreferrer" href="https://www.csdn.net/tags/MtTaEg3sOTA3MDM5LWJsb2cO0O0O.html">https://www.csdn.net/tags/MtTaEg3sOTA3MDM5LWJsb2cO0O0O.html</a></p>
<p>[8] <a target="_blank" rel="noopener external nofollow noreferrer" href="https://zhuanlan.zhihu.com/p/435769998">https://zhuanlan.zhihu.com/p/435769998</a></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:guojiaxiang0820@gmail.com" rel="external nofollow noreferrer">洛沐</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://www.guojxblog.cn/archives/330ac4a4.html">https://www.guojxblog.cn/archives/330ac4a4.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="external nofollow noreferrer" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://www.guojxblog.cn" target="_blank">洛沐の人间客栈</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/Python%E6%95%B0%E5%80%BC%E5%88%86%E6%9E%90/">Python数值分析</a></div><div class="post_share"><div class="social-share" data-image="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F%E4%B8%8EAdams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F%E6%B1%82%E8%A7%A3%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E5%88%9D%E5%80%BC%E9%97%AE%E9%A2%98/bubble.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/wechat.jpeg" rel="external nofollow noreferrer" target="_blank"><img class="post-qr-code-img" src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/wechat.jpeg" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/alipay.jpeg" rel="external nofollow noreferrer" target="_blank"><img class="post-qr-code-img" src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/alipay.jpeg" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/archives/1def5f0d.html"><img class="prev-cover" src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/ideas.jpeg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">我愿保持清醒的自知直到永远</div></div></a></div><div class="next-post pull-right"><a href="/archives/e84af901.html"><img class="next-cover" src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/%E5%AE%A1%E5%88%A4%E4%B8%8E%E8%87%AA%E6%88%91%E5%AE%A1%E5%88%A4/Judge.jpeg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">审判与自我审判</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/archives/a8ccf4cb.html" title="高斯——勒让德求积公式与复化高斯型求积公式(等距节点)误差分析"><img class="cover" src="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/loading3.gif" data-original="https://luomublog.oss-cn-qingdao.aliyuncs.com/ImgHost/ComeDate.jpeg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-05-15</div><div class="title">高斯——勒让德求积公式与复化高斯型求积公式(等距节点)误差分析</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="lv-container" data-id="city" data-uid="MTAyMC81NjIzOS8zMjcwMg=="></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content is-expand"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AE%9E%E9%AA%8C%E5%86%85%E5%AE%B9"><span class="toc-number">1.</span> <span class="toc-text">实验内容</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E7%AE%97%E6%B3%95%E5%8E%9F%E7%90%86"><span class="toc-number">2.</span> <span class="toc-text">算法原理</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%BB%8F%E5%85%B8%E5%9B%9B%E9%98%B6Runge-Kutta%E5%85%AC%E5%BC%8F"><span class="toc-number">2.1.</span> <span class="toc-text">经典四阶Runge-Kutta公式</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Adams%E9%A2%84%E6%B5%8B%E6%A0%A1%E6%AD%A3%E5%85%AC%E5%BC%8F"><span class="toc-number">2.2.</span> <span class="toc-text">Adams预测校正公式</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E7%A8%8B%E5%BA%8F%E6%A1%86%E5%9B%BE"><span class="toc-number">3.</span> <span class="toc-text">程序框图</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E7%BC%96%E7%A8%8B%E5%AE%9E%E7%8E%B0"><span class="toc-number">4.</span> <span class="toc-text">编程实现</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BB%A3%E7%A0%81%E8%AF%A6%E8%A7%A3"><span class="toc-number">4.1.</span> <span class="toc-text">代码详解</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%BF%90%E8%A1%8C%E7%BB%93%E6%9E%9C"><span class="toc-number">4.2.</span> <span class="toc-text">运行结果</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E7%BB%93%E6%9E%9C%E5%88%86%E6%9E%90%E4%B8%8E%E8%AE%A8%E8%AE%BA"><span class="toc-number">5.</span> <span class="toc-text">结果分析与讨论</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%8F%82%E8%80%83"><span class="toc-number">6.</span> <span class="toc-text">参考</span></a></li></ol></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2021 - 2023  <i id="heartbeat" class="fa fas fa-heartbeat"></i> 洛沐</div><div class="footer_custom_text">谢谢你来看<a href="https://www.guojxblog.cn/" style='color:red;Font-size:36'>我</a>，你今天真好看😘</div></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/HCLonely/images@master/others/heartbeat.min.css"></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">簡</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">本地搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/medium-zoom/dist/medium-zoom.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.autoSpacingPage()
  else {
    getScript('https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js')
      .then(() => {
        pangu.autoSpacingPage()
      })
  }
}

function panguInit () {
  if (false){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguInit)</script><script src="/js/search/local-search.js"></script><div class="js-pjax"><script>function loadLivere () {
  if (typeof LivereTower === 'object') {
    window.LivereTower.init()
  }
  else {
    (function(d, s) {
        var j, e = d.getElementsByTagName(s)[0];
        if (typeof LivereTower === 'function') { return; }
        j = d.createElement(s);
        j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
        j.async = true;
        e.parentNode.insertBefore(j, e);
    })(document, 'script');
  }
}

if ('Livere' === 'Livere' || !true) {
  if (true) btf.loadComment(document.getElementById('lv-container'), loadLivere)
  else loadLivere()
}
else {
  function loadOtherComment () {
    loadLivere()
  }
}</script></div><script src="/js/mobile_side.js"></script><script id="click-heart" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-heart.min.js" async="async" mobile="true"></script><div class="pjax-reload"><script async="async">var arr = document.getElementsByClassName('recent-post-item');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '1s');
    arr[i].setAttribute('data-wow-delay', '700ms');
    arr[i].setAttribute('data-wow-offset', '100');
    arr[i].setAttribute('data-wow-iteration', '1');
}</script><script async="async">var arr = document.getElementsByClassName('card-widget');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
}</script></div><script defer="defer" src="https://cdn.jsdelivr.net/gh/graingert/wow@1.3.0/dist/wow.min.js"></script><script defer="defer" src="/js/wow_init.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><script>
            window.imageLazyLoadSetting = {
                isSPA: true,
                preloadRatio: 3,
                processImages: null,
            };
        </script><script>window.addEventListener("load",function(){var t=/\.(gif|jpg|jpeg|tiff|png)$/i,r=/^data:image\/[a-z]+;base64,/;Array.prototype.slice.call(document.querySelectorAll("img[data-original]")).forEach(function(a){var e=a.parentNode;"A"===e.tagName&&(e.href.match(t)||e.href.match(r))&&(e.href=a.dataset.original)})});</script><script>!function(n){n.imageLazyLoadSetting.processImages=o;var e=n.imageLazyLoadSetting.isSPA,i=n.imageLazyLoadSetting.preloadRatio||1,r=Array.prototype.slice.call(document.querySelectorAll("img[data-original]"));function o(){e&&(r=Array.prototype.slice.call(document.querySelectorAll("img[data-original]")));for(var t,a=0;a<r.length;a++)0<=(t=(t=r[a]).getBoundingClientRect()).bottom&&0<=t.left&&t.top<=(n.innerHeight*i||document.documentElement.clientHeight*i)&&function(){var t,e,n,i,o=r[a];t=o,e=function(){r=r.filter(function(t){return o!==t})},n=new Image,i=t.getAttribute("data-original"),n.onload=function(){t.src=i,e&&e()},t.src!==i&&(n.src=i)}()}o(),n.addEventListener("scroll",function(){var t,e;t=o,e=n,clearTimeout(t.tId),t.tId=setTimeout(function(){t.call(e)},500)})}(this);</script><script async>window.onload=function(){var a=document.createElement('script'),b=document.getElementsByTagName('script')[0];a.type='text/javascript',a.async=!0,a.src='/sw-register.js?v='+Date.now(),b.parentNode.insertBefore(a,b)};</script></body></html>